package za.ac.wits.elen7045.persistence.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class DateUtilities {
	
	public static final String SHORT_DATE_FORMAT = "yyyyMMdd";
	public static final String LONG_DATE_FORMAT = "yyyyMMddHHmm";
	
	public static String getShortDateAsString(Date date) {
		return new SimpleDateFormat(SHORT_DATE_FORMAT).format(date);
	}

	public static String getLongDateAsString(Date date) {
		return new SimpleDateFormat(LONG_DATE_FORMAT).format(date);
	}
	
	public static Date getShortDateStringAsDate(String shortDate) {
		try {
			return new SimpleDateFormat(SHORT_DATE_FORMAT).parse(shortDate);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static Date getLongDateStringAsDate(String longDate) {
		try {
			return new SimpleDateFormat(LONG_DATE_FORMAT).parse(longDate);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}
	
}
